<?php 
$GLOBALS['Md'] = "MF93FL27";
$GLOBALS['Pd'] = "B";
require_once($_SERVER['DOCUMENT_ROOT']."/defaultconf.mex");
MYTCONN(); 

	$COL6 = 0;
	$RSGET = $GLOBALS['MYT']->db_array("SELECT REF AS O_ID,
											INVOICE AS COL1,
											CLIENT AS COL2,
											bns_Time AS COL3,
											OriNombre AS COL4,
											bns_Value AS COL5
						 FROM bonusinvoice
						INNER JOIN bonuspartners ON btt_ID = bns_Partner
						INNER JOIN origenes ON OriNumero = bns_Origen1
						 WHERE bns_Partner = {$_POST['bttPartners']} AND bns_Status = 2");
	$CARD = $RSGET[0]; ?>
<script charset="utf-8" type="text/javascript">
disableSelection(document.getElementById("rsresults"));

Ext.onReady(function(){

    Ext.QuickTips.init();

    var myData = [
	<?php   
	for ($i=1;$i<=$CARD;$i++) {
		$COL6 += $RSGET[$i]['COL5']; 
	echo '['.$i.','.$RSGET[$i]['O_ID'].',\''.$RSGET[$i]['COL1'].'\',\''.$RSGET[$i]['COL2'].'\',\''.$RSGET[$i]['COL3'].'\',\''.$RSGET[$i]['COL4'].'\',\''.$RSGET[$i]['COL5'].'\',\''.$COL6.'\']';
		if ($i<$CARD) {
			echo ',';
		}
    } ?>
    ];

    var ds = new Ext.data.Store({
        reader: new Ext.data.ArrayReader({}, [
               {name: 'id'},
			   {name: 'O_ID', type: 'int'},
               {name: 'COL1', type: 'string'},
               {name: 'COL2', type: 'string'},
               {name: 'COL3', type: 'string'},
			   {name: 'COL4', type: 'string'},
               {name: 'COL5', type: 'string'},
               {name: 'COL6', type: 'string'},
          ])
    });
    ds.loadData(myData);
    var colModel = new Ext.grid.ColumnModel([
        {header: "Numero", width: 80, sortable: true, locked:true, dataIndex: 'O_ID'},
        {header: "Movimento", width: 80, sortable: true, locked:true, dataIndex: 'COL1'},
        {header: "Data", width: 120, sortable: true, locked:true,dataIndex: 'COL3'},
        {header: "Cliente", width: 150, sortable: true, dataIndex: 'COL2'},
        {header: "Loja", width: 150, sortable: true, locked:true,dataIndex: 'COL4'},
        {header: "Valor", width: 120, sortable: true, locked:true,dataIndex: 'COL5'},
        {header: "Saldo", width: 75, sortable: true, locked:true,dataIndex: 'COL6'}
    ]);

   var selmode = new Ext.grid.RowSelectionModel({});
   var Console = new Ext.grid.GridPanel({
            columnWidth: 0.6,
	            ds: ds,
	            cm: colModel,
	            sm: selmode,
				listeners: {
	 				rowdblclick: function(ds, row) { 
					var record = ds.getStore().getAt(row);
  					var value = record.get('O_ID');	
					modalwindow(value);
					 }
				},
	            height: 250,
	            border: true,
        renderTo: 'rsresults'
    });
		
});
</script>